package api

import (
	"RESTful-api/pkg"
	"github.com/gin-gonic/gin"
	"net/http"
)

func UploadImg(c *gin.Context) {
	file, err := c.FormFile("file")
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code": http.StatusBadRequest,
			"msg":  "文件上传失败",
		})
		return
	}
	yun, err := pkg.ALiYun(file)
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code": http.StatusBadRequest,
			"msg":  "文件上传失败",
		})
		return
	}
	c.JSON(http.StatusBadRequest, gin.H{
		"code": http.StatusBadRequest,
		"msg":  "文件上传成功",
		"data": yun,
	})
}
